import { defineStore } from "pinia";

interface ObjectList {
  [key: string]: string[];
}

export const usePermissStore = defineStore("permiss", {
  state: () => {
    const defaultList: ObjectList = {
      admin: [
        "content", //内容管理 :/content
        "configuration", // 运营配置 :/configuration
        "playlistClassification", // 歌单分类管理 :/playlist-classification
        "playlistTags", //歌单标签管理 :/playlist-tags
        "songClassification", // 曲库分类管理 :/song-classification
        "songTags", //曲库标签管理 :/song-tags
        "copyRight", // 版权方管理 :/copy-right
        "subscriptionConfig", // 订阅配置 :/subscription-config
        "songRecommend", //曲库上新推荐 :/song-recommend
        "musicLibrary", // 曲库管理 :/music-library
        "subversionList", //子版本管理 :/subversion-list
        "orderManage", //订单管理 :/order-manage
        "userManage", // 用户管理:/user-manage
        "advertisementManage", // 广告管理:/advertisement-manage
        "roleManage", // 角色管理:/role-manage
        "accountManage", // 账号管理:/account-manage
      ],
    };
    const username = localStorage.getItem("vuems_name");
    const resourceCode = localStorage.getItem("resourceCode");
    return {
      key: (resourceCode?resourceCode:defaultList.admin) as string[],
      defaultList,
    };
  },
  actions: {
    handleSet(val: string[]) {
      this.key = val;
    },
  },
});
